import {httpClient} from '@/utils/request';
import lark from '@/config';
import Cookies from 'js-cookie';

export async function getAppToken(app_id, app_secret) {
  return await httpClient.post({
    url: lark.env.api.AUTH.V2_GET_APP_TOKEN,
    params: {
      'receive_type': 'input',
    },
    data: {
      app_id: app_id,
      app_secret: app_secret,
    },
  });
}

export function clearInfo() {
  // 异步函数
  httpClient.delete({url: lark.env.api.AUTH.V2_CLEAR_INFO}).then((_) => console.log(_));
}
// 云文档鉴权
export async function docSDK({type}) {
  const uuid = Cookies.get('uuid');
  return await httpClient.post({
    url: lark.env.api.AUTH.V2_DOC_SDK,
    data: {
      uuid,
      type,
      url: lark.env.runtime.hashRouter ? window.location.href.split('#')[0] : window.location.href,
    },
  });
}
